﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace syc.Sale
{
    public partial class ZhuangCheDan : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        public override void VerifyRenderingInServerForm(Control control)
        {

        }

        /// <summary>
        /// 导出到Word
        /// </summary>
        public void ExportToWord(String filetype, String filename)
        {
            Response.Clear();
            Response.Buffer = false;
            //注意对中文标题进行编码 

            Page.Response.AddHeader("content-disposition", "attachment; filename=\"" + Server.UrlEncode(filename) + ".doc");

            Response.Charset = "utf-8";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            this.EnableViewState = false;

            Page.Response.ContentType = filetype;
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            this.Render(htw);

            Response.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }

        protected void Button_Print_Click(object sender, EventArgs e)
        {
            this.Panel0.Visible = false;
            this.Panel2.Visible = false;
            this.Saler.Visible = false;
            this.TextBox1.Visible = false;
            this.Button_Print.Visible = false;
            this.Label1.Text = this.Saler.Text;
            this.Label2.Text = this.TextBox1.Text;
            this.TextBox1.Visible = false;
            this.Saler.Visible = false;
            this.Label1.Visible = true;
            this.Label2.Visible = true;
            this.lbl3.Text = this.txt2.Text;
            this.lbl3.Visible = true;
            this.txt2.Visible = false;
            this.lbl4.Text = this.txt3.Text;
            this.lbl4.Visible = true;
            this.txt3.Visible = false;
            this.lbl5.Text = this.txt4.Text;
            this.lbl5.Visible = true;
            this.txt4.Visible = false;
            ExportToWord("application/ms-word ", "zhuangchedan");
        }

        protected void Saler_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.Label1.Text = this.Saler.Text;
        }

        protected void Button_Query_Click(object sender, EventArgs e)
        {
            this.Label1.Text = this.Saler.Text;
        }

    }
}
